{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Load and Read the Results of Traditional Planner"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys; sys.path.append('../..')\n",
    "import h5py\n",
    "import numpy as np\n",
    "from utils.utils import print_stat_load\n",
    "tmp = '../../logs/trad_planner/'\n",
    "# -----------\n",
    "# pl = 'rrt'\n",
    "pl = 'bit'\n",
    "# pl = 'sipp' ## dynamic\n",
    "\n",
    "env_name = 'randSmaze2d-ng3ks25k-ms55nw6-hExt05-v0'\n",
    "# env_name = 'randSmaze2d-C43-ng3ks25k-ms55nw21-hExt05-v0'\n",
    "\n",
    "### ------ Dynamic ------\n",
    "# env_name = 'DynrandSmaze2d-ng1ks10k-ms55nw1-hExt10-v0'\n",
    "# suffix = '_2'\n",
    "\n",
    "suffix = ''\n",
    "fname = f'{tmp}/{env_name}-eval-{pl}{suffix}.hdf5'\n",
    "print('fname:', fname)\n",
    "\n",
    "with h5py.File(fname, 'r') as hf:\n",
    "    keys = list(hf.keys())\n",
    "    print(f'keys: {keys}')\n",
    "    probs = np.array(hf['problems'])\n",
    "    is_suc = np.array(hf['is_suc'])\n",
    "    n_colchk = np.array(hf['n_colchk'])\n",
    "    planning_time = np.array(hf['planning_time'])\n",
    "\n",
    "\n",
    "## --------- PRINT ----------\n",
    "np.set_printoptions(precision=3)\n",
    "is_sem, pl_sem, col_sem = print_stat_load(is_suc, planning_time, n_colchk)\n",
    "print( f'Suc Rate: {is_suc.mean()*100:.2f}, e{is_sem:.2f} ')\n",
    "print( f'Planning Time: {planning_time.mean():.2f}, e{pl_sem:.2f} ' )\n",
    "print( f'Collision Check: {n_colchk.mean():.2f}, e{col_sem:.2f}' )\n",
    "## ----------"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "torch2ss",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
